package common.fengkai.filepost.test;

import java.util.Scanner;
import java.util.regex.Pattern;

/**
 * @author Fengkai
 * @creat 2022/2/17
 */
public class Main {
   public static void main(String[] args){
       Scanner scanner = new Scanner(System.in);
       while (scanner.hasNextLine()) {
           String s = scanner.nextLine();
           if (s.length() <= 8){
               System.out.println("NG");
               continue;
           }
           if (!checkMatchString(s)){
               System.out.println("NG");
               continue;
           }
           if (checkRepactString(s)){
               System.out.println("NG");
               continue;
           }
           System.out.println("OK");
       }

      }
    //判断是否有重复子串
    private static  boolean checkRepactString(String s){
        for (int i = 0; i < s.length() - 2; i++) {
            String substring = s.substring(i, i + 3);
            for (int j = i + 1; j < s.length() - 3; j++) {
                if (s.substring(j, j+3).equals(substring)) {
                    return  true;
                }
            }
        }
        return false;
    }

    //正则表达式判断
    private static  boolean checkMatchString(String s){
        int count = 0;
        Pattern p1 = Pattern.compile("[A-Z]");
        if (p1.matcher(s).find()){
            count ++;
        }
        Pattern p2 = Pattern.compile("[a-z]");
        if (p2.matcher(s).find()){
            count++;
        }
        Pattern p3 = Pattern.compile("[^a-zA-Z0-9]");
        if (p3.matcher(s).find()){
            count++;
        }
        Pattern p4 = Pattern.compile("[0-9]");
        if (p4.matcher(s).find()){
            count++;
        }
        return count>=3?true:false;
    }



}
